<?php
require '../../base.php';
require '../../msg/MessageStatic.class.php';

if (!defined('DP_BASE_DIR')){
	die(MessageStatic::$notAccessMessage);
}

require DP_BASE_DIR .'/base/db/DBConnection.class.php';
require DP_BASE_DIR .'/base/db/CommonDAO.class.php';
require DP_BASE_DIR .'/integration/roe/SelectAppByLCROE.class.php';

$idLC = $_GET['lc'];

if (is_null($idLC)){
	header('Refresh: 0; ' . $urlApp .'/presentation/app/selectLCToApply.php');
}

$db=DBConnection::getInstance();
$selectAppByLCROE = new SelectAppByLCROE($db);

$result = $selectAppByLCROE->getStmtByLC($idLC);
$stTblResults = '';
if (($result)||(mysql_errno == 0))
{

		header('Content-Type: text/csv');
		header('Content-Disposition: attachment; filename="resumen.csv"');
		header('Pragma: no-cache');
		header('Expires: 0');

		$fp = fopen('php://output', 'w');
			
		$i=0;
		while ($i < mysql_num_fields($result)){	
			$encabezados[$i]=mysql_field_name($result, $i);
			$i++;	
		}
		
		fputcsv($fp, $encabezados,$delimitador = ';',$encerrador = '"');
		
		while ($filaresul = mysql_fetch_row($result)){
			fputcsv($fp, $filaresul,$delimitador = ';',$encerrador = '"');
		}
}

?>